package homework21.studyplan;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;

public class MontherDay {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Calendar calendar = Calendar.getInstance();
        System.out.print("请输入年份：");
        int year = input.nextInt();
        SimpleDateFormat sDF =new SimpleDateFormat("M月dd日");
        calendar.set(Calendar.YEAR,year);//Calendar中获取年份和月份及日期要单独赋值最后，获取总的时间时用getTime();
        calendar.set(Calendar.MONTH,Calendar.MAY);
        for (int i = 1; i <= 7; i++) {
            calendar.set(Calendar.DAY_OF_MONTH,i);
            if(calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){
                    calendar.set(Calendar.DAY_OF_MONTH,i + 7);
                    break;
            }

        }
        System.out.println(year + "年的母亲节是：" + sDF.format(calendar.getTime()));
    }
}
